﻿using System;
using System.Collections.ObjectModel;
using System.Windows;
using ClientBankWPF.Entities;
using ClientBankWPF.Service;

namespace ClientBankWPF
{
    /// <summary>
    /// Interaction logic for PaymentOrdersView.xaml
    /// </summary>
    public partial class PaymentOrdersView
    {
        private readonly DataAccessService dataAccessService;

        public PaymentOrdersView()
        {
            InitializeComponent();
        }

        public PaymentOrdersView(DataAccessService dataAccessService)
        {
            InitializeComponent();
            dateEditFrom.Text = DateTime.Now.ToString();
            dateEditFrom.DateTime = DateTime.Now;
            dateEditTo.Text = DateTime.Now.ToString();
            dateEditTo.DateTime = DateTime.Now;
            this.dataAccessService = dataAccessService;
        }

        private void ButtonGetPOListClick(object sender, RoutedEventArgs e)
        {
            GridControlPaymentOrders.DataSource = new ObservableCollection<PaymentOrder>(
                dataAccessService.GetPaymentOrders(dateEditFrom.DateTime, dateEditTo.DateTime));
        }
    }
}